package com.clstu.homeworks;

//四种修饰符的访问权限：

/**
 * public :在任意地方都可以访问，权限最大
 * protected:只在自己的包里面可以访问
 * 默认：跟protected权限差不多
 * private： 权限最小，方法一班不用private修饰，属性一般都用private修饰，只在自己的对象中可以访问
 *
 *
 *
 */

public class HomeWork01 {
    public static void main(String[] args) {
        Person[] persons=new Person[3];
        persons[0]=new Person("jack",20,"Teacher");
        persons[1]=new Person("Frank",18,"student");
        persons[2]=new Person("Marry",30,"Manager");
        Person temp=null;
        for (int i = 0; i < persons.length-1; i++) {
            for (int j = i+1; j < persons.length; j++) {
                if(persons[i].getAge()>persons[j].getAge()){
                    temp=persons[i];
                    persons[i]=persons[j];
                    persons[j]=temp;
                }
            }
        }
        for (int i = 0; i < persons.length; i++) {
            System.out.println(persons[i]);
        }


    }
}
class Person{
    private String name;
    private int age;
    private String job;

    public Person(String name, int age, String job) {
        this.name = name;
        this.age = age;
        this.job = job;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", job='" + job + '\'' +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }
}